/*
 * Copyright (C) 2018 The Asiainfo-Ability Authors
 *
 *      Licensed under the Apache License, Version 2.0 (the "License");
 *      you may not use this file except in compliance with the License.
 *      You may obtain a copy of the License at
 *
 *          http://www.apache.org/licenses/LICENSE-2.0
 *
 *      Unless required by applicable law or agreed to in writing, software
 *      distributed under the License is distributed on an "AS IS" BASIS,
 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *      See the License for the specific language governing permissions and
 *      limitations under the License.
 */

package org.asiainfo.ability.gateway.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.asiainfo.ability.base.code.InstanceState;
import org.asiainfo.ability.gateway.model.Instance;
import org.asiainfo.ability.gateway.model.Machine;
import org.asiainfo.ability.gateway.model.MicroService;
import org.asiainfo.ability.gateway.model.UserAbility;
import org.asiainfo.ability.gateway.vo.Page;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: visen
 * @Date: 2018/1/16
 * @Description:
 */
@Mapper
@Component
public interface ServiceDao {

    public MicroService loadService(String serviceName);
    public List<MicroService> listMicroServices(Page page);
    public int getServiceCount();
    public void saveMicroService(MicroService microService);
    public void updateMicroService(MicroService microService);
    public int deleteMicroService(String serviceName);


    public Machine loadMachine(long id);
    public List<Machine> listMachines();
    public void saveMachine(Machine machine);
    public int deleteMachine(long id);


    public int getInsCount(String serviceName);
    public int getActiveInsCount(String serviceName);
    public Instance loadInstance(long id);

    public List<Instance> listInstances(String serviceName);
    public Object getMaxPort(long machineId);
    public List<Instance> listInstancesInMachine(long machineId);

    public int isPortAlreadyUsed(@Param("machineId") long machineId, @Param("port") int port);
    public void saveInstance(Instance instance);
    public void updateInstance(Instance instance);
    public void updateInstanceState(@Param("id") long id, @Param("state")InstanceState instanceState);
    public int deleteInstance(long id);


    public UserAbility loadUserAbility(long id);
    public List<UserAbility> listUserAbilities(String clientId);
    public void saveUserAbility(UserAbility userAbility);
    public int updateUserAbility(UserAbility userAbility);
    public int deleteUserAbility(long id);



}
